﻿using B.Auth.APi.Application.Command.Role;
using B.Auth.Domain.Entity;
using B.Auth.Domain.Repository;
using B.Auth.Enum;
using MediatR;

namespace B.Auth.APi.Application.CommandHand.Role
{
    public class updataBoosRoleCommandHand : IRequestHandler<updataBoosRoleCommand, ApiResult<int>>
    {
        private readonly IBaseRepository<RoleModel> _role;

        public updataBoosRoleCommandHand(IBaseRepository<RoleModel> role)
        {
            _role = role;
        }

        public Task<ApiResult<int>> Handle(updataBoosRoleCommand request, CancellationToken cancellationToken)
        {
            var result = new ApiResult<int>();
            var booser = _role.GetAll().FirstOrDefault(x => x.Id == request.id);
            booser.Boos = request.bossid;
            _role.Update(booser);
            result.Message = "修改成功";
            result.Code = ApiEnum.ok;
            return Task.FromResult(result);

        }
    }
}
